package packVistas;

import java.awt.EventQueue;

import javax.swing.JDialog;
import javax.swing.JButton;

import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.JPanel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;

import java.awt.GridLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;

import javax.swing.JTable;

import java.awt.Insets;
import java.sql.ResultSet;
import java.util.ArrayList;

import javax.swing.table.DefaultTableModel;

import packLigaDeFutbol.EquipoPuntos;
import packLigaDeFutbol.GestorClasificacion;
import packLigaDeFutbol.UtilControles;


public class Clasificacion extends JDialog {
	private JTable tClasif;

	
	public Clasificacion() {
		setModal(true);
		setTitle("Clasificación");
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(new BorderLayout(0, 0));
		
		JPanel panel = new JPanel();
		getContentPane().add(panel, BorderLayout.WEST);
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.columnWidths = new int[]{196, 0, 0, 0, 0, 71, 0};
		gbl_panel.rowHeights = new int[]{224, 27, 0};
		gbl_panel.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
		gbl_panel.rowWeights = new double[]{1.0, 0.0, Double.MIN_VALUE};
		panel.setLayout(gbl_panel);
		GestorClasificacion c = new GestorClasificacion();
		ArrayList<EquipoPuntos> aep = c.calcularClasificacion();
		
		tClasif = new JTable();
		tClasif.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Equipo", "Puntos"
			}
		));
		UtilControles.cargarTablaConArray(tClasif, aep);
		GridBagConstraints gbc_tClasif = new GridBagConstraints();
		gbc_tClasif.gridwidth = 3;
		gbc_tClasif.insets = new Insets(0, 0, 5, 5);
		gbc_tClasif.fill = GridBagConstraints.BOTH;
		gbc_tClasif.gridx = 0;
		gbc_tClasif.gridy = 0;
		panel.add(tClasif, gbc_tClasif);
		
		JButton btnCerrar = new JButton("Cerrar");
		GridBagConstraints gbc_btnCerrar = new GridBagConstraints();
		gbc_btnCerrar.insets = new Insets(0, 0, 0, 5);
		gbc_btnCerrar.anchor = GridBagConstraints.NORTHWEST;
		gbc_btnCerrar.gridx = 1;
		gbc_btnCerrar.gridy = 1;
		panel.add(btnCerrar, gbc_btnCerrar);
		btnCerrar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});

	}

}
